Dynomotion

Group: DynoMotion Message: 8567 From: sahil_atlury Date: 11/4/2013
Subject: Reg: Homing - Y-Axis doesnt "Home" properly, stops inbetwe
Dear Friends,

Problem:

Both z and x-axis home properly, touching the limit switches and work as per the code, however the y-axis moves in the correct direction for about 3000-5000 steps and then automatically zeros and stops. It doesn't fully home itself.

We are using kmotion KMotion431n.exe  (along with latest firmware from it)

Sometimes, we get negative soft limit trigger without the axis actually reaching its soft limit value (happens on y-axis)

Sometimes in the axis window (axis status screen of kmotion), we notice that the values present in the position group are being picked up by the destination group. Is this normal?

We checked for noise but couldnt find any issues with that.

The machine is a home made 3-axis horizontal mill.

Initialization Code:

#include "KMotionDef.h"

// Defines axis 0, 1, 2 as simple step dir TTL outputs for KSTEP
// enables them
// sets them as an xyz coordinate system for GCode

int main()
{
    double T0, LastX=0, LastY=0, LastZ=0, Tau;
   
    KStepPresent=TRUE;      // enable KSTEP input multiplexing
    FPGA(KAN_TRIG_REG)=4;      // Mux PWM0 to JP7 Pin5 IO 44 for KSTEP

    FPGA(STEP_PULSE_LENGTH_ADD) = 63 + 0x80;  // set polarity and pulse length to 4us
   
    ch0->InputMode=NO_INPUT_MODE;
    ch0->OutputMode=STEP_DIR_MODE;
    ch0->Vel=4000;
    ch0->Accel=400000;
    ch0->Jerk=4e+006;
    ch0->P=0;
    ch0->I=0.01;
    ch0->D=0;
    ch0->FFAccel=0;
    ch0->FFVel=0;
    ch0->MaxI=200;
    ch0->MaxErr=1e+006;
    ch0->MaxOutput=200;
    ch0->DeadBandGain=1;
    ch0->DeadBandRange=0;
    ch0->InputChan0=0;
    ch0->InputChan1=0;
    ch0->OutputChan0=8;
    ch0->OutputChan1=0;
    ch0->MasterAxis=-1;
    ch0->LimitSwitchOptions=0x11f;
    ch0->LimitSwitchNegBit=179;
    ch0->LimitSwitchPosBit=178;
    ch0->SoftLimitPos=134178;
    ch0->SoftLimitNeg=-134178;
    ch0->InputGain0=-1;
    ch0->InputGain1=1;
    ch0->InputOffset0=0;
    ch0->InputOffset1=0;
    ch0->OutputGain=-1;
    ch0->OutputOffset=0;
    ch0->SlaveGain=1;
    ch0->BacklashMode=BACKLASH_OFF;
    ch0->BacklashAmount=0;
    ch0->BacklashRate=0;
    ch0->invDistPerCycle=1;
    ch0->Lead=0;
    ch0->MaxFollowingError=1000000000;
    ch0->StepperAmplitude=20;

    ch0->iir[0].B0=1;
    ch0->iir[0].B1=0;
    ch0->iir[0].B2=0;
    ch0->iir[0].A1=0;
    ch0->iir[0].A2=0;

    ch0->iir[1].B0=1;
    ch0->iir[1].B1=0;
    ch0->iir[1].B2=0;
    ch0->iir[1].A1=0;
    ch0->iir[1].A2=0;

    ch0->iir[2].B0=0.000769;
    ch0->iir[2].B1=0.001538;
    ch0->iir[2].B2=0.000769;
    ch0->iir[2].A1=1.92076;
    ch0->iir[2].A2=-0.923833;

    EnableAxisDest(0,0);

    ch1->InputMode=NO_INPUT_MODE;
    ch1->OutputMode=STEP_DIR_MODE;
    ch1->Vel=4000;
    ch1->Accel=400000;
    ch1->Jerk=4e+006;
    ch1->P=0;
    ch1->I=0.01;
    ch1->D=0;
    ch1->FFAccel=0;
    ch1->FFVel=0;
    ch1->MaxI=200;
    ch1->MaxErr=1e+006;
    ch1->MaxOutput=200;
    ch1->DeadBandGain=1;
    ch1->DeadBandRange=0;
    ch1->InputChan0=0;
    ch1->InputChan1=0;
    ch1->OutputChan0=9;
    ch1->OutputChan1=0;
    ch1->MasterAxis=-1;
    ch1->LimitSwitchOptions=0x11f;
    ch1->LimitSwitchNegBit=181;
    ch1->LimitSwitchPosBit=180;
    ch1->SoftLimitPos=95611.2;
    ch1->SoftLimitNeg=-95611.2;
    ch1->InputGain0=1;
    ch1->InputGain1=1;
    ch1->InputOffset0=0;
    ch1->InputOffset1=0;
    ch1->OutputGain=1;
    ch1->OutputOffset=0;
    ch1->SlaveGain=1;
    ch1->BacklashMode=BACKLASH_OFF;
    ch1->BacklashAmount=0;
    ch1->BacklashRate=0;
    ch1->invDistPerCycle=1;
    ch1->Lead=0;
    ch1->MaxFollowingError=1000000000;
    ch1->StepperAmplitude=20;
   
    ch1->iir[0].B0=1;
    ch1->iir[0].B1=0;
    ch1->iir[0].B2=0;
    ch1->iir[0].A1=0;
    ch1->iir[0].A2=0;

    ch1->iir[1].B0=1;
    ch1->iir[1].B1=0;
    ch1->iir[1].B2=0;
    ch1->iir[1].A1=0;
    ch1->iir[1].A2=0;

    ch1->iir[2].B0=0.000769;
    ch1->iir[2].B1=0.001538;
    ch1->iir[2].B2=0.000769;
    ch1->iir[2].A1=1.92076;
    ch1->iir[2].A2=-0.923833;


    EnableAxisDest(1,0);

    ch2->InputMode=NO_INPUT_MODE;
    ch2->OutputMode=STEP_DIR_MODE;
    ch2->Vel=4000;
    ch2->Accel=400000;
    ch2->Jerk=4e+006;
    ch2->P=0;
    ch2->I=0.01;
    ch2->D=0;
    ch2->FFAccel=0;
    ch2->FFVel=0;
    ch2->MaxI=200;
    ch2->MaxErr=1e+006;
    ch2->MaxOutput=200;
    ch2->DeadBandGain=1;
    ch2->DeadBandRange=0;
    ch2->InputChan0=0;
    ch2->InputChan1=0;
    ch2->OutputChan0=10;
    ch2->OutputChan1=0;
    ch2->MasterAxis=-1;
    ch2->LimitSwitchOptions=0x11f;
    ch2->LimitSwitchNegBit=182;
    ch2->LimitSwitchPosBit=183;
    ch2->SoftLimitPos=93321.5;
    ch2->SoftLimitNeg=-93321.5;
    ch2->InputGain0=1;
    ch2->InputGain1=1;
    ch2->InputOffset0=0;
    ch2->InputOffset1=0;
    ch2->OutputGain=1;
    ch2->OutputOffset=0;
    ch2->SlaveGain=1;
    ch2->BacklashMode=BACKLASH_OFF;
    ch2->BacklashAmount=0;
    ch2->BacklashRate=0;
    ch2->invDistPerCycle=1;
    ch2->Lead=0;
    ch2->MaxFollowingError=1000000000;
    ch2->StepperAmplitude=20;

    ch2->iir[0].B0=1;
    ch2->iir[0].B1=0;
    ch2->iir[0].B2=0;
    ch2->iir[0].A1=0;
    ch2->iir[0].A2=0;

    ch2->iir[1].B0=1;
    ch2->iir[1].B1=0;
    ch2->iir[1].B2=0;
    ch2->iir[1].A1=0;
    ch2->iir[1].A2=0;

    ch2->iir[2].B0=0.000769;
    ch2->iir[2].B1=0.001538;
    ch2->iir[2].B2=0.000769;
    ch2->iir[2].A1=1.92076;
    ch2->iir[2].A2=-0.923833;

    EnableAxisDest(2,0);

    DefineCoordSystem(0,1,2,-1);
   
    SetBitDirection(45,1);  // set Enable Signal as Output
    SetBit(45);                // Enable the amplifiers
   
//  Add a small amount of Coordinated Motion Path smoothing if desired
//    Tau = 0.001;  // seconds for Low Pass Filter Time Constant
//    KLP = exp(-TIMEBASE/Tau);
    KLP=0; // force to 0 to disable
//    printf("Tau=%f KLP=%f\n",Tau,KLP);
   
    /*
    for (;;) // loop forever
    {
        WaitNextTimeSlice();
       
        // Service Amplifier disable after no activity for a while
        if (ch0->Dest != LastX || ch1->Dest != LastY || ch2->Dest != LastZ)
        {
            // we moved - enable KStep Amplifers
            SetBit(45);
            T0 = Time_sec();  // record the time and position of last motion
            LastX=ch0->Dest;
            LastY=ch1->Dest;
            LastZ=ch2->Dest;
        }
        else
        {
            if (Time_sec() > T0 + 10.0) ClearBit(45);
        }
       
       
        if (ReadBit(180) == 0)
        {
            printf("Bit State Pressed");
        }
    }
    */

    return 0;
}


Homing Code:

#include "KMotionDef.h"

// Configuration and Homing program for a 3 axis System
// Limit switches are disabled and used as a home switch
// then they are re-enabled


main()
{
    int SaveXLimits,SaveYLimits,SaveZLimits;  //place to save limit switch settings
   
    DisableAxis(0);  // Disable all axes
    DisableAxis(1);
    DisableAxis(2);

    // Set the axis parameters here
    // after everything is configured in the KMotion Screens
    // use copy C Code to clipboard on the configuration screen
    // then paste here.  Repeat for each axis
   
    // disable the limits (first save how they were set)
    SaveXLimits = ch0->LimitSwitchOptions;
    SaveYLimits = ch1->LimitSwitchOptions;
    SaveZLimits = ch2->LimitSwitchOptions;
    ch0->LimitSwitchOptions = 0;
    ch1->LimitSwitchOptions = 0;
    ch2->LimitSwitchOptions = 0;
   
       
    // enable all 3 axes and begin servoing where we are
   
    EnableAxis(0);
    EnableAxis(1);
    EnableAxis(2);


    // Home Z up first - jog until it sees the limit

    Jog(2,600);             // jog slowly positive
   
    while (ReadBit(183)) ;  // loop until IO bit goes high
    Jog(2,0);
                // stop
    while (!CheckDone(2)) ; // loop until motion completes
    DisableAxis(2);            // disable the axis
   
    Zero(2);                // Zero the position
    EnableAxis(2);            // re-enable the ServoTick
    Move(2,-1000.0);        // move some amount inside the limits
    while (!CheckDone(2)) ; // loop until motion completes
    ch2->LimitSwitchOptions = SaveZLimits;  // restore limit settings


   
    // Home X next - jog until it sees the limit

    Jog(0,-600);              // jog slowly negative
    while (ReadBit(179)) ;  // loop until IO bit goes high
    Jog(0,0);                // stop
    while (!CheckDone(0)) ; // loop until motion completes
    DisableAxis(0);            // disable the axis
    Zero(0);                // Zero the position
    EnableAxis(0);            // re-enable the ServoTick
    Move(0,1000.0);            // move some amount inside the limits
    while (!CheckDone(0)) ; // loop until motion completes
    ch0->LimitSwitchOptions = SaveXLimits;  // restore limit settings


// Home Y next - jog until it sees the limit

    Jog(1,-600);              // jog slowly negative
    while (ReadBit(181)) ;      // loop until IO bit goes high
    Jog(1,0);                // stop
    while (!CheckDone(1)) ; // loop until motion completes
    DisableAxis(1);            // disable the axis
    Zero(1);                // Zero the position
    EnableAxisDest(1,-95611.2);
    //EnableAxis(1);            // re-enable the ServoTick
    Move(1,-94611.2);
    //Move(1,1000.0);            // move some amount inside the limits
    while (!CheckDone(1)) ; // loop until motion completes
    ch1->LimitSwitchOptions = SaveYLimits;  // restore limit settings

   
    DefineCoordSystem(0,1,2,-1);  //Define XYZ coordinated motion axes
}


Do help us
Thanking you